package com.txt.hander;

import com.txt.exception.BusinessException;
import com.txt.result.R;
import io.swagger.v3.oas.annotations.Hidden;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Hidden
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(BusinessException.class)
    public R<String> exception(BusinessException e) {
        e.printStackTrace();
        return R.fail(e.getMsg());
    }
    @ExceptionHandler(Exception.class)
    public R<String> exception(Exception e) {
        e.printStackTrace();
        return R.fail(e.getMessage());
    }
}
